﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using CE.Global;

public partial class Provider_CarInsurance_TableMatching : System.Web.UI.Page
{
    string PageName = "CXCI";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.ProviderCompanyId] == null)
        {
            Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        }
        CheckMainPageAccess();
        CheckSubPageAccess();

        if (Session[CE.Global.General.ProviderCompanyId].ToString() == "29") //Liberty
        {
            divLiberty.Visible = true;
            divEtiqa.Visible = false;
            divHSBC.Visible = false;
            divRSA.Visible = false;
            divDA.Visible = false;
        }
        else if (Session[CE.Global.General.ProviderCompanyId].ToString() == "30") //Etiqa
        {
            divLiberty.Visible = false;
            divEtiqa.Visible = true;
            divHSBC.Visible = false;
            divRSA.Visible = false;
            divDA.Visible = false;
        }
        else if (Session[CE.Global.General.ProviderCompanyId].ToString() == "23") //HSBC
        {
            divLiberty.Visible = false;
            divEtiqa.Visible = false;
            divHSBC.Visible = true;
            divRSA.Visible = false;
            divDA.Visible = false;
        }
        else if (Session[CE.Global.General.ProviderCompanyId].ToString() == "24") //RSA
        {
            divLiberty.Visible = false;
            divEtiqa.Visible = false;
            divHSBC.Visible = false;
            divRSA.Visible = true;
            divDA.Visible = false;
        }
        else if (Session[CE.Global.General.ProviderCompanyId].ToString() == "38") //DirectAsia
        {
            divLiberty.Visible = false;
            divEtiqa.Visible = false;
            divHSBC.Visible = false;
            divRSA.Visible = false;
            divDA.Visible = true;
        }
        //lnkInsurance
        //if (Session[CE.Global.General.ProviderCompanyId].ToString() == "29")
        //{
        //    lnkInsurance.NavigateUrl = "~/Provider/CarInsurance/ViewLibertyInsurance.aspx";
        //}
        //else if (Session[CE.Global.General.ProviderCompanyId].ToString() == "30")
        //{
        //    lnkInsurance.NavigateUrl = "~/Provider/CarInsurance/ViewEtiqaInsurance.aspx";
        //}

    }


    private void CheckMainPageAccess()
    {
        Int64 PageAccess = General.GetProviderMainPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), PageName);
        if (PageAccess == 0)
        {
            //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
            Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
        }
    }

    private void CheckSubPageAccess()
    {
        Int64 PageAccess = General.GetProviderSubPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                        Convert.ToInt64(Session[General.UserId].ToString()), "CXCITEST");
        if (PageAccess == 0)
        {
            lnkTestCarInsurance.Visible = false;
            HyperLink33.Visible = false;
            HyperLink49.Visible = false;
        }
    }

}
